package dao;

import java.util.List;

import model.ProductType;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;

import util.HibernateUtil;

public class ProductTypeDAO {
	private Session session;
	public ProductTypeDAO() {
		this.session = HibernateUtil.getSessionFactory().openSession();
	}
	public List<ProductType> getAllProductType() {
		List<ProductType> ds = null;
		try {
			session.beginTransaction();
			Criteria cri = session.createCriteria(ProductType.class);
			ds = cri.list();
			session.getTransaction().commit();
		} catch (HibernateException ex) {
			if (session.getTransaction() != null) {
				session.getTransaction().rollback();
			}
			ex.printStackTrace();
		} finally {
			session.close();
		}
		return ds;
	}
}
